pygrub: Support GPT (GUID Partition Table) as used by EFI.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 11 Apr 2007 14:27:14 +0000 (15:27 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 11 Apr 2007 14:27:14 +0000 (15:27 +0100)
Signed-off-by: Shinya Kuwamura <kuwa@jp.fujitsu.com>
Signed-off-by: Tomohiro Takahashi <takatom@jp.fujitsu.com>
tools/pygrub/src/pygrub

index 8f4e3473f792850bdcb2593921499997e1bffb06..99c2debd4043628843965dfc5b1d3a9ac9d4799f 100644 (file)
@@ -59,6 +59,13 @@ def get_active_partition(file):
         if struct.unpack("<c", buf[poff:poff+1]) == ('\x80',):
             return buf[poff:poff+16]
 
+        # type=0xee: GUID partition table
+        # XXX assume the first partition is active
+        if struct.unpack("<c", buf[poff+4:poff+5]) == ('\xee',):
+            os.lseek(fd, 0x400, 0)
+            buf = os.read(fd, 512)
+            return buf[24:40] # XXX buf[32:40]
+
     # if there's not a partition marked as active, fall back to
     # the first partition
     return buf[446:446+16]